<?php
	require_once 'Zend/Session/Namespace.php';
	require_once './libs/phpbb.php';

	// Session namespace
	$authNamespace = new Zend_Session_Namespace('gcmsadmin');
   	if ($authNamespace->admin != true)
		exit();

	// Fetch topics
	if (isset($_POST['path'])) {
		if (!file_exists($_POST['path'] . '/config.php')) {
			echo Zend_Json::encode(array(array('forum_id' => '', 'forum_name' => '[phpBB3 not found]')));
			exit();
		}
		$phpbb = new Zend_PHPBB3($_POST['path']);
		echo Zend_Json::encode($phpbb->get_forums());
	}
?>